﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Commonality.ValidateModel
{
    /// <summary>
    /// 自定义验证方法例子，对比实际情况
    /// </summary>
    public class MixAttribute : BaseValidateAttribute
    {
        public int Mix { get; set; }
        public MixAttribute(int mix)
        {
            Mix = mix;
        }
        public override ValiResult ValiResult(object value)
        {
            var zhValue = value.ToString().Length;
            if (zhValue > Mix)
            {
                return new ValiResult() { IsSuccess = false, Message = "长度超出预设" };

            }
            else
            {
                return new ValiResult() { IsSuccess = true };
            }
        }
    }
}
